package com.peg.rules;

import com.peg.dataobjects.Context;

/**
 * @author sad
 */
public class PushMatch extends Rule {

    private String _prefix = null;

    public PushMatch(String prefix) {
        _prefix = prefix;
    }

    public PushMatch() {
    }

    @Override
    public boolean execute(Context context) {
        if (_prefix == null) {
            context.getStack().Push(context.getMatch());
        } else {
            context.getStack().Push(_prefix + context.getMatch());
        }

        return true;
    }

    @Override
    public String toString() {
        return "PushMatch";
    }
}
